/*
 * This file is part of SSHTTPD.
 *
 * SSHTTPD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * SSHTTPD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/** @file
 * Defines global structures and functions implemented and used by response.c
 */
#ifndef _RESPONSE_H
#define _RESPONSE_H

/* App includes. */
#include "file.h"
#include "request.h"

/** Holds the data required for a http response. */
typedef struct httpresp {
	/** HTTP status code. */
        int scode; 
	/** Header only flag. */
	int header; 
	/** HTTP version string. */
        char *ver;
	/** Status string. */
	char *sstring;         
	/** Metafile with disk data. */
	mfile_t *file;
} httpresp_t;

/**
 * Builds a response struture out of a request structure.
 * @param Request to build response to. 
 * @return Response structure on success, needs to be destroy'd.
 */
httpresp_t *build_response(httpr_t *request);

/** 
 * Destroys a response structure allocated with build_response().
 * @param resp Response to destroy. 
 */
void destroy_response(httpresp_t *resp);

/**
 * Sends a response to the client.
 * @param resp Response to send.
 * @param ud Clients socket descriptor. 
 * @return Amount of data sent.
 */
int send_response(httpresp_t *resp, int ud);

#endif
